package org.weso.acota.to.feedback;

import java.util.LinkedList;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

@XmlRootElement(name = "feedbackResource")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "feedbackResource", propOrder = {
    "title",
    "description",
    "source",
    "subject",
    "tagged"
})
public class FeedbackResource {
	private String title;
	private String description;
	private String source;
	private String subject;
	private List<FeedbackTag> tagged;
	
	public FeedbackResource(){
		title = "";
		description = "";
		source = "";
		subject = "";
		tagged = new LinkedList<FeedbackTag>();
	}
	
	public FeedbackResource(String title, String description, String source,
			String subject, List<FeedbackTag> tagged) {
		super();
		this.title = title;
		this.description = description;
		this.source = source;
		this.subject = subject;
		if(tagged == null){
			this.tagged = new LinkedList<FeedbackTag>();
		}else{
			this.tagged = tagged;
		}
	}

	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}

	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}

	public String getSource() {
		return source;
	}
	public void setSource(String source) {
		this.source = source;
	}

	public String getSubject() {
		return subject;
	}
	public void setSubject(String subject) {
		this.subject = subject;
	}

	public List<FeedbackTag> getTagged() {
		return tagged;
	}
	public void setTagged(List<FeedbackTag> tagged) {
		this.tagged = tagged;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((description == null) ? 0 : description.hashCode());
		result = prime * result + ((source == null) ? 0 : source.hashCode());
		result = prime * result + ((subject == null) ? 0 : subject.hashCode());
		result = prime * result + ((tagged == null) ? 0 : tagged.hashCode());
		result = prime * result + ((title == null) ? 0 : title.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		FeedbackResource other = (FeedbackResource) obj;
		if (description == null) {
			if (other.description != null)
				return false;
		} else if (!description.equals(other.description))
			return false;
		if (source == null) {
			if (other.source != null)
				return false;
		} else if (!source.equals(other.source))
			return false;
		if (subject == null) {
			if (other.subject != null)
				return false;
		} else if (!subject.equals(other.subject))
			return false;
		if (tagged == null) {
			if (other.tagged != null)
				return false;
		} else if (!tagged.equals(other.tagged))
			return false;
		if (title == null) {
			if (other.title != null)
				return false;
		} else if (!title.equals(other.title))
			return false;
		return true;
	}
	
}
